package com.yungu.swift.api.route.v2.trade;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yungu.swift.api.base.BaseApi;
import com.yungu.swift.base.ResponseData;
import com.yungu.swift.order.model.param.RefundParam;
import com.yungu.swift.order.service.RefundService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping(value = "/api/v2/trade/refund")
@Api(value = "【交易】【退款】通用接口", tags = "退款相关操作")
public class RefundApi extends BaseApi {

    @Reference
    private RefundService refundService;

    @RequestMapping(value = {"/create"}, method = RequestMethod.POST)
    @ApiOperation(value = "创建退款接口", notes = "create", response = ResponseData.class)
    public ResponseData<Integer> create(@RequestBody RefundParam refundParam, HttpServletRequest request) {
        refundParam.setCreateBy(getUserUid(request));
        return refundService.refund(refundParam);
    }

    @RequestMapping(value = {"/query"}, method = RequestMethod.POST)
    @ApiOperation(value = "退款查询接口", notes = "query", response = ResponseData.class)
    public ResponseData<Boolean> query(@RequestBody RefundParam refundParam, HttpServletRequest request) {
        return refundService.refundQuery(refundParam.getOrderUuid(), getUserUid(request));
    }
}
